<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/6/21
 * Time: 15:19
 */

namespace ElementVip\JwOms\Handler;

use ElementVip\JwOms\Services\OrderService;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Bus\Queueable;

class OrderHandle extends AbstractOms
{
//    use InteractsWithQueue, Queueable, SerializesModels;

    protected $orderService;

    public function __construct(OrderService $orderService)
    {
        $this->orderService = $orderService;
    }

    public function handle()
    {        
        //上传订单数据
        \Log::info('进入了上传订单数据');
        $data = $this->orderService->getOrdersData();
        if ($data['data']) {
            \Log::info('进入了创建订单文件');
            $this->createFile('Order', 'sh', $data);
        }

        //同步发货状态
        \Log::info('进入了同步发货状态');
        if (count($file = $this->downloadFiles('OrderSendShip')) > 0) {
            foreach ($file as $item) {
                $this->orderService->orderShip($item);
            }
        }
    }


}